package com.seeyon.apps.seepkk.manager;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.alibaba.fastjson.JSONArray;
import com.seeyon.apps.kk.constants.Constants;
import com.seeyon.apps.kk.manager.AdapterSyncDataManager;
import com.seeyon.apps.kk.util.TTUtils;

public class SyncCustManager extends AdapterSyncDataManager {
	private static final Log log = LogFactory.getLog(SyncCustManager.class); 
	private String url;
	private String token;
	private String interfaceNo;
	@Override
	public boolean isUnflow() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public String getFormCode() {
		// TODO Auto-generated method stub
		return Constants.Cust;
	}

	@Override
	public String getSendUser() {
		// TODO Auto-generated method stub
		return Constants.createUser;
	}

	@Override
	public void delHistoryData() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Map> getSyncData() {
		// TODO Auto-generated method stub
		JSONArray dataAry=TTUtils.simsResource(url, token, interfaceNo);
		return dataAry.toJavaList(Map.class);
		/*return null;*/
	}

	@Override
	public Map<String, Object> data2FormMap(Map params) {
		Map<String, Object> map =new HashMap<String, Object>();
		map.put("CUST_CD", MapUtils.getObject(params, "CUST_CD"));
		map.put("Cust_Desc_CN", MapUtils.getObject(params, "CUST_DESC_CN"));
		map.put("Cust_Desc_EN", MapUtils.getObject(params, "CUST_DESC_EN"));
		map.put("CUST_TYPE", MapUtils.getObject(params, "CUST_TYPE_NAME"));
		map.put("CUST_TYPE_CD", MapUtils.getObject(params, "CUST_TYPE_CD"));
		map.put("CLASS", MapUtils.getObject(params, "HP_LVL_NAME"));
		map.put("CATEGORY", MapUtils.getObject(params, "HP_CUSTTYPE_NAME"));
		map.put("Province_CD", MapUtils.getObject(params, "PROVINCE_NAME"));
		map.put("City_CD", MapUtils.getObject(params, "CITY_NAME"));
		map.put("COUNTY", "");
		map.put("Address", MapUtils.getObject(params, "ADDRESS")); 
		map.put("PHONE_NO", MapUtils.getObject(params, "PHONE_NO"));
		map.put("FAX_NO", MapUtils.getObject(params, "FAX_NO"));
		map.put("ZIP_CD", MapUtils.getObject(params, "ZIP_CD"));
		map.put("人员ID", "");
		return map;
	}

	@Override
	public Object vaildateDataUnique() {
		// TODO Auto-generated method stub
		Map<String, Object> map =new HashMap<String, Object>();
		map.put("main","CUST_CD");
		return map;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getInterfaceNo() {
		return interfaceNo;
	}

	public void setInterfaceNo(String interfaceNo) {
		this.interfaceNo = interfaceNo;
	}
}
